<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            var findBottomLeftValue = function (root) {
                if (!root) return 0
                function levelOrder(root) {
                    let res = []
                    let queue = [root]
                    while (queue.length) {
                        res.push([])
                        let len = queue.length
                        for (let i = 0; i < len; i++) {
                            let node = queue.shift()
                            res[res.length - 1].push(node.val)
                            if (node.left) {
                                queue.push(node.left)
                            }
                            if (node.right) {
                                queue.push(node.right)
                            }
                        }
                    }
                    return res
                }
                let res = levelOrder(root)
                return res[res.length - 1][0]
            }
        </script>
    </body>
</html>
